<?php
  if (!defined('EXPONENT')) exit('');
  if (exponent_users_isAdmin() ||  exponent_permissions_check(array("administrate"),$loc))
  {   
      exponent_flow_set(SYS_FLOW_PROTECTED,SYS_FLOW_ACTION);
      
      // page title
      global $db;
      //$temp = $db->selectObject("container", "internal = '".serialize($loc)."'");
      //$config = $db->selectObject("linklistmodule_config", "location_data = '".serialize($loc)."'");
      
      $title = "";
      if ($temp->title == "")
        $title = $config->force_title;
      else
        $title = $temp->title;
      
      require_once(BASE."modules/formhelpermodule/formhelper.php");
      //$formhelper=new formhelper("linklistmodule","_manager_linklist_title","_manager_linklist",$loc);
      $formhelper=new formhelper("linklistmodule","Manage ".$title,"_manager_linklist",$loc);
        $formhelper->setGridType(FORMHELPER_GRID_TYPE_DATAGRID);
        $formhelper->setGridOptions("height",800);
        $formhelper->setGridOptions("idField","id");
        $formhelper->setGridOptions("pagination",1);
        $formhelper->setGridOptions("pageNumber","1");
        $formhelper->setGridOptions("pageSize","20");
        $formhelper->setGridOptions("rownumbers","true");
        $formhelper->setGridOptions("nowrap","false");
        $formhelper->setGridOptions("singleSelect","true");
        $formhelper->setGridOptions("autoRowHeight","true");
        
        $formhelper->setGridID("manage_link");
        $js=URL_FULL."modules/documentsmodule/js/Manager_Link.js";
        $formhelper->addJS($js);
        
        $css=URL_FULL."modules/documentsmodule/css/Manager_Link.css";
        $formhelper->addCss($css);
        
        $formhelper->setColumnType(1);
        $formhelper->addColumn(array("field"=>"name","title"=>"Name",'width'=>130));
        $formhelper->addColumn(array("field"=>"author","title"=>"Author",'width'=>100));
        $formhelper->addColumn(array("field"=>"series_name","title"=>"Series",'width'=>100));
        $formhelper->addColumn(array("field"=>"post_date","title"=>"Date",'width'=>120, "sortable"=>false));
        $formhelper->addColumn(array("field"=>"download","title"=>"Download",'width'=>50, "sortable"=>true));
        //$formhelper->addColumn(array("field"=>"rank","title"=>"Rank",'width'=>50, "sortable"=>true));
        $link_param="/index.php?module=documentsmodule&action=manage_getjson&src={$loc->src}&ajax_action=1";
        $formhelper->setURLDataStream($link_param);
        $formhelper->setGridOptions("onBeforeLoad","function(___form_onBeforeLoad");
        $toolbar_template=new template("documentsmodule","_Manager_Link_ToolbarHTML",$loc);
        $toolbar_template->register_permissions(array('administrate',"configure"),$loc);
        $toolbar_html=$toolbar_template->render();
        $formhelper->addToolbarHTML($toolbar_html);
        $formhelper->setPreInitJSCall("form_syslog_preinit");
        $formhelper->register_permissions(array('administrate',"configure"),$loc);
        $formhelper->output();
  }
  else
    {
        echo SITE_403_HTML;
    }
?>
